<template>
  <div>
    <el-row>
      <h1 align="left">搜索结果 for 【{{this.$route.params.queryContent}}】</h1>
    </el-row>
    <hr>
    <el-card align="left" shadow="hover" v-for="res in Result" :key="res.key">
      <router-link :to="'/doc/?url='+res"><h3>{{res}}</h3></router-link>
    </el-card>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'SearchResult',
  data() {
    return {
      Result: [],
    };
  },
  created() {
    this.update_this(this.$route.params.queryContent);
  },
  methods: {
    update_this(query_content) {
      axios.get('/api/common/search', { params: { query_content } }).then((res) => {
        this.Result = res.data;
      });
    },
  },
  watch: {
    $route(to) {
      this.update_this(to.params.queryContent);
    },
  },
};
</script>

<style scoped>

</style>
